<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${rootPath}/css/a.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/index.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/common.css" type="text/css" rel="stylesheet" />
<title>终端序列号号段查询</title>

<script type="text/javascript" src="<s:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript" src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>

<!-- 当前页面样式 -->
<script type="text/javascript" src="<s:url value="/js/jquery-1.9.1.js" />"></script>
	
<!-- jQuery UI 插件 -->
<script src=<s:url value="/js/ui/jquery.ui.core.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.widget.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.position.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.menu.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.autocomplete.js"/>></script>
<script type='text/javascript' src='<s:url value="/js/querySon.js"/>'></script>

<link rel="stylesheet" href=<s:url value="/css/demos.css"/>>
	
<style>
		 .fieldError { color: red; text-align: left; }
		.error { float: none; color: red;  vertical-align: top;font-size: 11px;}
		.ui-autocomplete {
		max-height: 200px;
		overflow-y:auto;
		overflow-x: hidden;
	}
	/* IE 6 doesn't support max-height
	 * we use height instead, but this forces the menu to always be this tall
	 */
	* html .ui-autocomplete {
		height: 100px;
	}
</style>

<script type="text/javascript">
$(document).ready(function(){

      var orgCode=$("#orgCode").val();
      if(orgCode != ''){
      	//loadOCode();
      }

      $("#sub").click(function(){
         var orgCode = $("#orgCode").val();
    	if(orgCode == ''){
           alert("请选择机构");
           return false;
         } 
         
         $("#queryForm").attr("action","<%=basePath%>/terminalSnBatch/queryTerminalSNBatch.ct");
		 $("#queryForm").submit();
       
      });			

    	// 仓库SN号段导入
      $("#snBatchLend").click(function() {
  		var id = 'terminalSnBatchLeading';
  		var title = '仓库SN号段导入';
  		var html = "<%=basePath%>/terminalSnBatchLeading/terminalSnBatchLeadingJsp.ct";
  		window.parent.parent.document.getElementById("framemain").contentWindow.addtabs(id,title,html);
  	   });

		// 仓库SN号段文本框导入
		$("#snBatchTxtLend").click(function() {
			var id = 'terminalSnBatchTxtLeading';
			var title = '仓库SN号段文本框导入';
			var html = "<%=basePath%>/terminalSnBatchTxtLeading/terminalSnBatchTxtLeadingJsp.ct";
			window.parent.parent.document.getElementById("framemain").contentWindow.addtabs(id,title,html);
		});
   });

   function loadOCode(){
        var orgCode = $("#orgCode").val();
		if (!orgCode) {
			return;
		}
		
		MccQuery.loadOCode(orgCode, function(sortSmall) {
			fillSelect_sort("accountNo", sortSmall);
		});
   }

	function delTerminalSNBatch(id){
		
		if(!window.confirm("您确定要删除吗？")){
		  return;
		}
		$("#queryForm").attr("action","${rootPath}/terminalSnBatch/delTerminalSNBatch.ct?batchNo=" + id);
		$("#queryForm").submit();
	}
</script>
</head>
<body>
<table class="tb">
    <tbody>
		<s:form id="queryForm" action="queryTerminalSNBatch.ct" method="post" namespace="/terminalSnBatch"  theme="simple">
			
        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h2">POS收单运营管理平台</div><font color="red">提示：终端品牌、型号后台规整中</font></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h3">终端SN号段查询</div></td>
        </tr>
		<tr class="tb-line">
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">批次：</div>
			</td>
			<td class="tb-td" >
			    <label class="tb-input-normal">
					<s:textfield id="batchNo" name="searchCondition.batchNo" cssClass="queryWidth" />
				</label>
            </td>
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">开始序列号：</div>
			</td>
			<td class="tb-td" >
			    <label class="tb-input-normal">
					<s:textfield id="beginSerialNum" name="searchCondition.beginSerialNum" cssClass="queryWidth" />
				</label>
            </td>
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">结束序列号：</div>
			</td>
			<td class="tb-td" >
			    <label class="tb-input-normal">
					<s:textfield id="endSerialNum" name="searchCondition.endSerialNum" cssClass="queryWidth" />
				</label>
            </td>
		</tr>
		<tr>
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		    	<div class="tb-h4">品牌：</div>
		    </td>
			<td class="tb-td">
				<label class="tb-select">
					<s:select cssClass="queryWidth" name="searchCondition.posBrand" id="posBrand"
						list="#request.brandMap" listKey="key" listValue="value" onchange="loadBrandCode()" 
						headerKey="-1" headerValue="--请选择--"/>
				</label>
			</td>
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		    	<div class="tb-h4">代理商名称：</div>
		    </td>
			<td class="tb-td" >
            	<span>
					<input id="showOneAgentId" name="searchCondition.agentId"  type="hidden"/>
					<input id="showOneAgentName" name="searchCondition.agentName"  placeholder="输入代理商名称" style="width:300px;"
						value="<s:property value="searchCondition.agentName"/>" />
				</span>	
			</td>
			<s:if test="#session.session_merchant.roleType==\"03\"||#session.session_merchant.roleType==\"15\" || #session.session_merchant.roleType==\"16\"">
				<td align="right" width="15%"></td>
					<td class="tb-td">
			    	<s:hidden name="searchCondition.orgCode" value="%{#session.session_merchant.orgCode}" id="orgCode" />
				</td>
			</s:if>	
			<s:else>
			   	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
			    	<div class="tb-h4">所属机构：</div>
			    </td>
				<td class="tb-td">
	                <label class="tb-select">
						<s:select cssClass="queryWidth" name="searchCondition.orgCode"
							id="orgCode" list="orgList" listKey="InsIdCd" listValue="InsName"/>
	            	</label>
				</td>
		</s:else>
	</tr>
				<tr>
					<td colspan="6" align="center"><div style="color: blue;">
							<s:actionmessage />
						</div>
						<div style="color: red;">
							<s:actionerror />
						</div>
					</td>
				</tr>

				<tr class="tb-line">
					<td class="tb-td line-submit" align="right" colspan="6">
                		<label class="tb-input-submit">
					 		<s:submit value="查询" id="sub" /> 
		                </label>
		                <label class="tb-input-submit">
				             <s:reset value="取  消" />
		                </label>
		                <label class="tb-input-submit">
							<input type="button" id="snBatchLend" value="仓库SN号段导入" >
		                </label>
		                <label class="tb-input-submit">
							<input type="button" id="snBatchTxtLend" value="仓库SN号段文本框导入" >
		                </label>
					</td>
				</tr>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<s:if
					test="#request.searchRsList != null && #request.searchRsList.size>0">
					<tr class="tb-line">
						<td class="tb-td paging" colspan="12" align="left">&nbsp;&nbsp;&nbsp;&nbsp; <page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/terminalSnBatch/queryTerminalSNBatch.ct?currentPage=" />

						</td>
					</tr>
				</s:if>
			</table> 
		</s:form>
    </tbody>
</table>
<div class="big-tb">
    <table class="tb" style="width: 100%;">
				<thead>
		            <tr class="tb-line">
		                <th class="tb-th" colspan="13">SN号段信息列表</th>
		            </tr>
					<tr class="tb-line bg-gray">
					    <th class="tb-th">号段</th>
					    <th class="tb-th">开始序列号</th>
					    <th class="tb-th">结束序列号</th>
					    <th class="tb-th">数量</th>
						<th class="tb-th">所属代理商</th>
						<th class="tb-th">厂商</th>
						 <s:if test="#session.session_merchant.roleType!=\"03\" && #session.session_merchant.roleType!=\"15\" && #session.session_merchant.roleType!=\"16\"">
						    <th class="tb-th">所属机构</th>
						 </s:if>
					<!-- 	<th class="tb-th">备注</th> -->
						<th class="tb-th">创建时间</th>
						<th class="tb-th">更新时间</th>
						<th class="tb-th">操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="term">
						<tr class="tb-line">
							<td class="tb-td" align="center">
							 <s:property value="#term.batchNo"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.beginSerialNum"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.endSerialNum"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.nums"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.agentName"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posBrand"/>
							</td>
							 <s:if test="#session.session_merchant.roleType!=\"03\" && #session.session_merchant.roleType!=\"15\" && #session.session_merchant.roleType!=\"16\"">
						       <td class="tb-td" align="center">
								 <s:property value="#term.orgName"/>
								</td>
						     </s:if>
							<td class="tb-td" align="center">
							 <s:property value="#term.dtCreateStr"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.dtLastmodStr"/>
							</td>
							<td class="tb-td" align="center">
								<a href="javascript:delTerminalSNBatch('<s:property value="#term.batchNo"/>')">删除</a>
							</td>
						</tr>
						</s:iterator>
				</tbody>
    </table>
</div>

<script type="text/javascript">

    $(function() {
    	autoGetAgentInfoByName();
	});
</script>
</body>
</html>